home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Games / Pentominoes 2.0 / Pent code / pent editor window.c < prev    next >
Text File  |  1995-07-30  |  22KB  |  162 lines

  1. ListHandle();
  2.     LActivate(TRUE, groupList);
  3.     LActivate(TRUE, boardList);
  4.     MyDrawActiveListBorder(groupList, GroupListActiveQQ());
  5.     MyDrawActiveListBorder(boardList, BoardListActiveQQ());
  6.     DrawGrowIconNoLines(theWindow, drawGrowIconLines);
  7. }
  8.  
  9. void DeactivateTheEditorWindow(WindowRef theWindow)
  10. {
  11.     Rect            tempRect;
  12.     ListHandle        groupList, boardList;
  13.     short            theDepth;
  14.     
  15.     theDepth=GetWindowDepth(theWindow);
  16.     groupList=GetGroupListHandle();
  17.     boardList=GetBoardListHandle();
  18.     LActivate(FALSE, groupList);
  19.     LActivate(FALSE, boardList);
  20.     MyDrawActiveListBorder(groupList, FALSE);
  21.     MyDrawActiveListBorder(boardList, FALSE);
  22.     tempRect.bottom=theWindow->portRect.bottom;
  23.     tempRect.right=theWindow->portRect.right;
  24.     tempRect.top=tempRect.bottom-kGrowBoxSize+1;
  25.     tempRect.left=tempRect.right-kGrowBoxSize+1;
  26.     if (theDepth>2)
  27.     {
  28.         tempRect.left++;
  29.         tempRect.top++;
  30.     }
  31.     EraseRect(&tempRect);
  32. }
  33.  
  34. void ResizeTheEditorWindow(WindowRef theWindow)
  35. {
  36.     ResizeEditorLists(theWindow, DEAD_SPACE_H, DEAD_SPACE_V, kHeaderHeight);
  37.     ResizeTheEditorBoard(theWindow);
  38. }
  39.  
  40. void GetGrowSizeTheEditorWindow(Rect *sizeRect)
  41. {
  42.     GetGrowSizeTheLists(sizeRect, DEAD_SPACE_H, DEAD_SPACE_V, HEADER_SPACE);
  43. }
  44.  
  45. void CopybitsTheEditorWindow(WindowRef theWindow, WindowRef offscreenWindowRef, Boolean active,
  46.     Boolean drawGrowIconLines)
  47. {
  48.     Rect            tempRect;
  49.     RgnHandle        copyRgn, listRgn;
  50.     ListHandle        groupList, boardList;
  51.     Rect            groupListRect, boardListRect;
  52.     
  53.     groupList=GetGroupListHandle();
  54.     boardList=GetBoardListHandle();
  55.     GetGroupListRect(&groupListRect);
  56.     GetBoardListRect(&boardListRect);
  57.     
  58.     copyRgn=NewRgn();
  59.     listRgn=NewRgn();
  60.     RectRgn(copyRgn, &(theWindow->portRect));
  61.     RectRgn(listRgn, &groupListRect);
  62.     InsetRgn(listRgn, -4, -4);
  63.     DiffRgn(copyRgn, listRgn, copyRgn);
  64.     SetEmptyRgn(listRgn);
  65.     RectRgn(listRgn, &boardListRect);
  66.     InsetRgn(listRgn, -4, -4);
  67.     DiffRgn(copyRgn, listRgn, copyRgn);
  68.     
  69.     CopyBits(    &(offscreenWindowRef->portBits),
  70.                 &(theWindow->portBits),
  71.                 &(offscreenWindowRef->portRect),
  72.                 &(theWindow->portRect), 0, copyRgn);
  73.     
  74.     if (active)
  75.     {
  76.         DrawGrowIconNoLines(theWindow, drawGrowIconLines);
  77.     }
  78.     else
  79.     {
  80.         tempRect.bottom=theWindow->portRect.bottom;
  81.         tempRect.right=theWindow->portRect.right;
  82.         tempRect.left=tempRect.right-kGrowBoxSize+1;
  83.         tempRect.top=tempRect.bottom-kGrowBoxSize+1;
  84.         EraseRect(&tempRect);
  85.     }
  86.     
  87.     UpdateEditorLists(theWindow);
  88.     
  89.     DisposeRgn(copyRgn);
  90.     DisposeRgn(listRgn);
  91. }
  92.  
  93. void DrawTheEditorWindow(WindowRef theWindow, short theDepth)
  94. {
  95.     RGBColor        oldForeColor, oldBackColor;
  96.     GrafPtr            curPort;
  97.     Rect            groupListRect;
  98.     
  99.     if (theDepth>2)
  100.     {
  101.         GetForeColor(&oldForeColor);
  102.         GetBackColor(&oldBackColor);
  103.     }
  104.     
  105.     GetPort(&curPort);
  106.     EraseRect(&(curPort->portRect));
  107.     
  108.     if (kHeaderHeight>0)
  109.     {
  110.         DrawEditorHeader(theWindow, theDepth);
  111.     }
  112.     
  113.     GetGroupListRect(&groupListRect);
  114.     DrawSoftWindowBorder(theWindow, theDepth, groupListRect.bottom+DEAD_SPACE_V, TRUE);
  115.     DrawTheEditorBoard(theWindow, theDepth);
  116.     
  117.     if (theDepth>2)
  118.     {
  119.         RGBForeColor(&oldForeColor);
  120.         RGBBackColor(&oldBackColor);
  121.     }
  122. }
  123.  
  124. void SetTheEditorMessage(WindowRef theWindow, short messageIndex, Boolean redraw)
  125. {
  126.     Str255            theStr;
  127.     
  128.     if ((messageIndex==kFreeTilesMessage) && (gCurrentBoardRec.numRows==0))
  129.         messageIndex=kBlankMessage;
  130.     if (messageIndex>0)
  131.         GetIndString(gTheMessage, kEditorMessagesID, messageIndex);
  132.     if (messageIndex==kFreeTilesMessage)
  133.     {
  134.         NumToString(FreeTiles(), theStr);
  135.         AppendStr255(gTheMessage, theStr);
  136.         AppendStr255(gTheMessage, "\p of ");
  137.         NumToString(gCurrentBoardRec.numRows*gCurrentBoardRec.numColumns, theStr);
  138.         AppendStr255(gTheMessage, theStr);
  139.     }
  140.     gTheMessageID=messageIndex;
  141.     if (redraw)
  142.         DrawTheEditorMessage(theWindow, FALSE);
  143. }
  144.  
  145. void UpdateEditorButtons(WindowRef theWindow, Boolean onlyIfChanged)
  146. {
  147.     short            i;
  148.     short            theDepth;
  149.     
  150.     if (!gShowToolbar)
  151.         return;
  152.     
  153.     theDepth=GetWindowDepth(theWindow);
  154.     for (i=0; i<NUM_BUTTONS; i++)
  155.     {
  156.         if ((!onlyIfChanged) || (ButtonIsDimmedQQ(theWindow, i)!=gOldButtonState[i]))
  157.             Draw3DButton(&gButtonRect[i], 0L, gButtonIcon[i], theDepth, kSquareButton+
  158.                 (ButtonIsDimmedQQ(theWindow, i) ? kButtonIsDimmed : 0));
  159.     }
  160. }
  161.  
  162. short GetEdi